package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.CrsUserLog;
import com.ruoyi.bizsys.service.ICrsUserLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * crs_user 剔除记录Controller
 *
 * @author ygw
 * @date 2022-08-22
 */
@RestController
@RequestMapping("/bizsys/crsUserLog")
public class CrsUserLogController extends BaseController {
    @Autowired
    private ICrsUserLogService crsUserLogService;

    /**
     * 查询crs_user 剔除记录列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrsUserLog crsUserLog) {
        startPage();
        List<CrsUserLog> list = crsUserLogService.selectCrsUserLogList(crsUserLog);
        return getDataTable(list);
    }

    /**
     * 导出crs_user 剔除记录列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:log:export')")
    @Log(title = "crs_user 剔除记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CrsUserLog crsUserLog) {
        List<CrsUserLog> list = crsUserLogService.selectCrsUserLogList(crsUserLog);
        ExcelUtil<CrsUserLog> util = new ExcelUtil<CrsUserLog>(CrsUserLog.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 获取crs_user 剔除记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(crsUserLogService.selectCrsUserLogById(id));
    }

    /**
     * 新增crs_user 剔除记录
     */
    @PreAuthorize("@ss.hasPermi('bizsys:log:add')")
    @Log(title = "crs_user 剔除记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrsUserLog crsUserLog) {
        return toAjax(crsUserLogService.insertCrsUserLog(crsUserLog));
    }

    /**
     * 修改crs_user 剔除记录
     */
    @PreAuthorize("@ss.hasPermi('bizsys:log:edit')")
    @Log(title = "crs_user 剔除记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrsUserLog crsUserLog) {
        return toAjax(crsUserLogService.updateCrsUserLog(crsUserLog));
    }

    /**
     * 删除crs_user 剔除记录
     */
    @PreAuthorize("@ss.hasPermi('bizsys:log:remove')")
    @Log(title = "crs_user 剔除记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(crsUserLogService.deleteCrsUserLogByIds(ids));
    }
}
